 <#include "../common/com.html"/> <@layout>

<!-- ace styles -->
<link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />
<link href='${ctx}/static/assets/css/select2.css' media='all'
	rel='stylesheet' type='text/css' />
<script src='${ctx}/static/assets/js/select2.min.js'
	type='text/javascript'></script>
<script src='${ctx}/static/assets/js/select2_locale_zh-CN.js'
	type='text/javascript'></script>
<script type="text/javascript">
	/**
	 * 新增
	 */
	function saveModel() {
		var id = document.getElementById("id").value;
		if (Validator.Validate(document.getElementById('form1'))) {
		} else {
			return;
		}

		url = '';
		if (id == "") {
			url = '${ctx}/hyglJfjl/save';
		} else {
			url = '${ctx}/hyglJfjl/update';
		}
		$('#form1').form('submit', {
			url : url,
			onSubmit : function() {
				return $(this).form('validate');
			},
			success : function(data) {
				alert(data);
				parent.location.reload();
			}
		});

	}
</script>
<div class="page-content">
	<div class="row-fluid">
		<div class="span12">
			<form class="form-horizontal" id="form1" method="post">
				<input type="hidden" name="id" id="id">
				<div class="control-group">
					<label class="control-label">消费积分:</label>
					<div class="controls">
						<input id="xfjf" name="xfjf" type="text" dataType="Require" msg="请输入消费积分"  maxlength="6"
						 class="easyui-numberbox" 	style="width: 200px; min-height: 24px;" /> 
					</div>
				</div>
			
				
				<div class="control-group">
					<label class="control-label">商品名称:</label>
					<div class="controls">
						<input id="wpid" name="wpid" type="text" onchange="getmc()"
							style="width: 200px; min-height: 24px;" /> <input id="wpmc"
							dataType="Require" msg="请选择商品" name="wpmc" type="hidden"
							style="min-height: 24px;" />
					</div>
				</div>


				<div class="control-group">
					<label class="control-label">服务种类:</label>
					<div class="controls">
						<input id="fwlxid" name="fwlxid" onclick="getfwmc();" type="text"
							style="min-height: 24px; width: 200px;" /> <input id="fwlxmc"
							name="fwlxmc" type="hidden" style="min-height: 24px;" />
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">开始日期:</label>
					<div class="controls">
						<input id="start" name="start" type="text"  dataType="Require" msg="请输入开始日期"
							onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'end\')}'})"   class="Wdate" />
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">结束日常:</label>
					<div class="controls">
						<input id="end" name="end" type="text"   dataType="Require" msg="请输入结束日期"
							 onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'start\')}'})"  class="Wdate" />
					</div>
				</div>



			</form>
		</div>
		<div class="span12 center">
			<a class="btn btn-info btn-small" onclick="saveModel()">确定 <a
				href="#" class="btn btn-danger btn-small bigger-110"
				onclick="window.location.href=' ${ctx}/hyglJfjl'">取消 </a>
		</div>
	</div>
</div>

</body>

<script>
	/**
	 * 修改页面使用
	 */
	 /**
		 * 修改页面使用
		 */
		 jQuery(function($) {
			 $('#wpid').select2({
			        placeholder: "请输入查询商品名称或者编号",
			        minimumInputLength: 0,
			        ajax: {
			            url: "${ctx}/cgglWp/getWpxx",
			            dataType: 'json',
			            data: function (term, page) {
			                return {
			                    term: term,
			                    page_limit: 50,
			                    page: 0,
			                    apikey: "getwpxx"
			                };
			            },
			            results: function (data, page) {
			                return { results: data};
			            }

			        }
			    });

			    $('#fwlxid').select2({
			        placeholder: "请输入服务类型",
			        minimumInputLength: 0,
			        ajax: {
			            url: "${ctx}/cgglWp/getFwzl",
			            dataType: 'json',
			            data: function (term, page) {
			                return {
			                    term: term,
			                    page_limit: 50,
			                    page: 0,
			                    apikey: "getFwzl"
			                };
			            },
			            results: function (data, page) {
			                return { results: data};
			            }

			        }
			    });
		
			   });
		  function getmc(){
		        var data = $("#wpid").select2("data");
		        var objs=JSONstringify(data);
		        var arr = eval('(' + objs + ')');
		        document.getElementById("wpmc").value=(arr['text']==undefined ) ? "" : arr['text'];
		    }
		    function getfwmc(){
		        var data = $("#fwlxid").select2("data");
		        var objs=JSONstringify(data);
		        var arr = eval('(' + objs + ')');
		        document.getElementById("fwlxmc").value=(arr['text']==undefined ) ? "" : arr['text'];
		    }
		    
		  //转json
		    function JSONstringify(Json){
		        if($.browser.msie){
		            if($.browser.version=="7.0"||$.browser.version=="6.0"){
		                var  result=jQuery.parseJSON(Json);
		            }else{
		                var result=JSON.stringify(Json);
		            }
		        }else{
		            var result=JSON.stringify(Json);
		        }
		        return result;
		    }
	<#list newlist as m>
	document.getElementById("wpid").value = '${(m.wpid)!}';
	document.getElementById("wpmc").value = '${(m.wpmc)!}';
	document.getElementById("fwlxid").value = '${(m.fwlxid)!}';
	document.getElementById("fwlxmc").value = '${(m.fwlxmc)!}';
	document.getElementById("start").value = '${(m.start)!}';
	document.getElementById("end").value = '${(m.end)!}';

	</#list>
</script>
</@layout>
